﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板

namespace wenku8.Xamls.SettingPages
{
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class SettingPage : Page
    {
        public SettingPage()
        {
            this.InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            MainPage.DisableProgressRing();
            base.OnNavigatedTo(e);
        }

        private async void ClearHeadImg_Click(object sender, RoutedEventArgs e)
        {
            var folder = await ApplicationData.Current.LocalCacheFolder
                        .CreateFolderAsync("headImageCache", CreationCollisionOption.OpenIfExists);
            await folder.DeleteAsync(StorageDeleteOption.PermanentDelete);
            folder = await ApplicationData.Current.LocalCacheFolder
                        .CreateFolderAsync("headImageCache", CreationCollisionOption.OpenIfExists);
        }

        private async void ClearCover_Click(object sender, RoutedEventArgs e)
        {
            var folder = await ApplicationData.Current.LocalCacheFolder
                        .CreateFolderAsync("coverCache", CreationCollisionOption.OpenIfExists);
            await folder.DeleteAsync(StorageDeleteOption.PermanentDelete);
            folder = await ApplicationData.Current.LocalCacheFolder
                        .CreateFolderAsync("coverCache", CreationCollisionOption.OpenIfExists);
        }

        private async void ClearIllustration_Click(object sender, RoutedEventArgs e)
        {
            var folder = await KnownFolders.PicturesLibrary
                        .CreateFolderAsync("illustration", CreationCollisionOption.OpenIfExists);
            await folder.DeleteAsync(StorageDeleteOption.PermanentDelete);
            folder = await KnownFolders.PicturesLibrary
                        .CreateFolderAsync("illustration", CreationCollisionOption.OpenIfExists);
        }
    }
}
